package com.zsj.hello.five;

import com.rabbitmq.client.CancelCallback;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;
import com.rabbitmq.client.Delivery;
import com.zsj.hello.util.RabbimqFactoryUtil;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * @author https://gitee.com/zhengshengjun
 * @date 2023/9/14.
 */
public class Consumer {

    public static void main(String[] args) throws IOException, TimeoutException {
        Channel channel = RabbimqFactoryUtil.getRabbitMQChannel();
        System.out.println("开始接收消息");
        DeliverCallback deliverCallback = (consumerTag, message) -> {
            System.out.println("接收的消息" + message);
            System.out.println(consumerTag);
        };


        CancelCallback cancelCallback = (consumerTag) -> {
            System.out.println("取消的消息" + consumerTag);
        };


        channel.basicConsume(Producer_1.QUEUE_NAME, deliverCallback, cancelCallback);

    }
}
